import { Router } from 'express';
import {
  createGroup,
  listGroups,
  getGroupMembers,
  inviteToGroup,
  leaveGroup,
  deleteGroup
} from '../controllers/group.controller';
import { authMiddleware } from '../middlewares/auth.middleware';

const router = Router();

router.use(authMiddleware);

router.post('/create', createGroup); // 创建群聊
router.get('/list', listGroups); //获取群列表

// ✅ 群成员相关接口
router.get('/:id/members', getGroupMembers); //获取群成员
router.post('/:id/invite', inviteToGroup); //邀请成员
router.delete('/:id/leave', leaveGroup); //退出群聊
router.delete('/:id', deleteGroup); //解散群聊

export default router;
